import React from 'react'
import { Table, Tag } from 'antd'
// import { withRouter } from 'react-router-dom'
function Newspublish(props) {
    const columns = [{
        title: "新闻标题",
        dataIndex: "title",
        render: (title, item) => {
            return <a href={`/news-manage/preview/${item.id}`}>{title}</a>
        }
    }, {
        title: "作者",
        dataIndex: "author"
    }, {
        title: "新闻分类",
        dataIndex: "category",
        render: (category) => {
            return <Tag color="gold">{category.title}</Tag>
        }
    }, {
        title: "操作",
        render: (item) => {
            // if (item.publishState === 1) {
            //     return < Button type="primary" onClick={() => publish(item)}> 发布</Button >
            // } else if (item.publishState === 2) {
            //     return < Button type="primary" onClick={() => down(item)}> 下线 </Button >
            // } else {
            //     return < Button type="primary" onClick={() => del(item)} danger>删除</Button >
            // }
            return <div>{props.button(item.id)}</div>
        }
    }]
    // const publish = (item) => {
    //     console.log("123", item)
    // }
    // const down = (item) => {
    //     console.log(item);
    // }
    // const del = (item) => {
    //     console.log(item)
    // }
    return (
        <div>
            <Table columns={columns} dataSource={props.dataSource}
                pagination={{
                    pageSize: 5
                }}
                rowKey={item => item.id}>
            </Table>
        </div>
    )
}
export default Newspublish